package com.wanxi.test;

import java.util.Scanner;

public class Login {
    public static void main(String[] args) {
        /**
         * 1.定义用户名和密码
         * 2.调用用户输入接口，得到用户输入的用户名和密码
         * 3.判断是否相等
         * 4.循环遍历
         */
        String username = "supeng";
        String password = "123456";
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入用户名");
            String user = scanner.next();
            System.out.println("请输入密码");
            String pass = scanner.next();
            if (username.equals(user) && password.equals(pass)) {
                System.out.println("登录成功");
                return;
            } else {
                System.out.println("用户名或者密码错误");
                System.out.println("你还有" + (2 - i) + "机会");
            }
        }
        System.out.println("三次机会用完，账户已冻结");
    }
}
